<?php
class sitemap_models_index extends CI_Model {
	public function sitemap(){
		$this->load->database();
		$query = $this->db->get_where('category', array('active' => 1));
		$data=array();
		if($query->num_rows()){
			foreach ($query->result() as $row)
				$data[]= $row->link.'/';
		}

		$query = $this->db->get('departement_region');
		if($query->num_rows()){
			foreach ($query->result() as $row)
				$data[]= 'annonce/region/'.$row->region_link;
		}

		$query = $this->db->get_where('product', array('prd_active' => 1));
		if($query->num_rows()){
			foreach ($query->result() as $row){
				$link='';
				$queryCat = $this->db->get_where('category', array('active' => 1,'id'=>$row->category_id),1);
				if($queryCat->num_rows()){
					$rowCat=$queryCat->result();
					$link= $rowCat[0]->link;
				}
				$link.=$row->prd_link.'.html';
				$data[]= $link;
			}
		}
		
		$query = $this->db->get_where('shop', array('shop_active' => 1));
		if($query->num_rows()){
			foreach ($query->result() as $row)
				$data[]= 'boutique/'.$row->shop_link.'.html';
		}


		$query = $this->db->get_where('page_article', array('page_active' => 1));
		if($query->num_rows()){
			foreach ($query->result() as $row)
				$data[]= $row->page_link.'.html';
		}
		
		
		return $data;
	}
}